#ifndef ERROR_H
#define ERROR_H
#include <stdbool.h>
/*
	词法错误码
*/
typedef enum lex_err_code
{
	ID_2_LONG, 		// 标识符过长
	NUM_2_LONG,     // 数字过长
	STR_2_LONG,		// 字符串过长
	COMMENT_NO_END,	// 多行注释没有正常结束
	STR_INCOMPLT,	// 字符串缺少右引号
	CHARA_INCOMPLT, // 字符不完整
	OR_NO_PAIR,		// “||”不完整
	UNRECOGNIZED_TOKEN,	// 无法识别的词法记号
	EMPTY_CHARA,   // 字符常量为空
	UNKNOW_ESCAPE_SEQUENCE, // 未知转义字符
	LEX_ERR_CODE_NUM,
} lex_err_code_e;

/*
	语法错误码
*/
typedef enum syn_err_code
{
	EXPECTED_TYPE,			// 期待类型关键字， data definition has no type
	EXPECTED_ID,              // error: expected identifier
	EXPECTED_LPAREN,
	EXPECTED_RPAREN,
	EXPECTED_LBRACKET,
	EXPECTED_RBRACKET, 
	EXPECTED_LBRACES,
	EXPECTED_RBRACES,
	EXPECTED_COMMA,
	EXPECTED_SEMICOLON, 
	EXPECTED_EQUAL_MARK,
	EXPECTED_COLON,
	EXPECTED_WHILE,
	ARR_SIZE_NEGATIVE_OR_ZERO,  //  error: size of array ‘xx’ is negative
	EXPECTED_LITERAL_OR_EXPR, // 缺少常量或者表达式
	EXPECTED_LITERAL, // 缺少常量
	FORBIDS_NESTED_FUNCTIONS,
	ARR_SIZE_NO_CONSTANT,
	CASE_LABEL_NOT_INT_CONSTANT,
	NEED_STATEMENT,
	IGNORE_TOKEN,
	SYN_ERR_CODE_NUM,  

} syn_err_code_e;

typedef enum err_level{
	WARNING,
	ERROR,
}err_level_e;

#define LOST  		1
#define NOT_MATCH 	2
#define OTHER       3

void lex_err(lex_err_code_e code, err_level_e lvl);
void show_error_num(void);
void syn_err(syn_err_code_e code,  err_level_e lvl, int cause, const char *name);
void recovery(bool cond, syn_err_code_e code,  err_level_e lvl);
void recovery_until_type(bool cond, syn_err_code_e code,  err_level_e lvl);
#endif